A DIY Smart Home Guide by Robert Chin

A DIY Smart Home Guide by Robert Chin

Author:Robert Chin
Language: eng
Format: epub
Publisher: McGraw-Hill Education
Published: 2020-04-11T16:00:00+00:00


Setting Up the Software

The new code for this hands-on example consists of the Arduino code that was modified from the regular LED control example. The same Android program which is the basic wireless framework program version 1.1 is used here to control the piezo buzzer. Only the modifications to the previous Arduino LED control program will be discussed in this section.

The BuzzerPin variable holds the Arduino digital pin number that is connected to the positive terminal of the piezo buzzer.

int BuzzerPin = 7;

The Freq variable holds the frequency in hertz of the tone that the buzzer will produce when active and is set by default to 500 hertz.

int Freq = 500;

The BuzzerOn variable is true if the buzzer is currently producing a sound and false otherwise.

boolean BuzzerOn = false;

The SirenOn variable is true if the buzzer is currently in siren mode.

boolean SirenOn = false;

The SirenOffTime variable holds the time in milliseconds that the buzzer should be off during siren mode and has a default value of 1000 milliseconds or 1 second.

int SirenOffTime = 1000;

The SirenOnTime variable holds the time in milliseconds that the buzzer should be on during siren mode and has a default value of 1000 milliseconds or 1 second.

int SirenOnTime = 1000;

The SirenStartTime variable holds the start time of the siren on time and the siren off time. It is used to keep track of the duration of the siren on time and the siren off time.

unsigned long SirenStartTime = 0;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.